package ai.zixing.powermock.mockprivate;

/**
 * <a href="https://www.baeldung.com/powermock-private-method">...</a>
 */
public class LuckyNumberGenerator {

    public int getLuckyNumber(String name) {
        saveIntoDatabase(name);
        if (name == null) {
            return getDefaultLuckyNumber();
        }
        return getComputedLuckyNumber(name.length());
    }

    private int getComputedLuckyNumber(int length) {
        return length < 5 ? 5 : 10000;
    }

    private int getDefaultLuckyNumber() {
        return 100;
    }

    private void saveIntoDatabase(String name) {
        System.out.println("LuckyNumberGenerator.saveIntoDatabase======== " + name);
    }
}
